Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: add failing writes with destroy test #19852

Closed

Conversation

mafintosh
Copy link
Member

@mafintosh mafintosh commented Apr 6, 2018

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Simplified the failing http2 test from #19828 into this test case. Basically when doing lots of writes and then destroying the request, the process will hang instead of exiting normally.

Fixes #20630

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Apr 6, 2018
@mafintosh
Copy link
Member Author

/cc @jasnell @addaleax

@mafintosh mafintosh added the http2 Issues or PRs related to the http2 subsystem. label Apr 6, 2018
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need to be rebased due to #19854, sorry :/


setTimeout(() => {
assert(false, 'should exit before 10s');
}, 10000).unref();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've been removing these kinds of checks to avoid timeout-related flakiness in tests -- the test runner enforces its own timeout anyway. (/cc @Trott)

If you want to have actual timing guarantees, you can try to remove the dependency on networking and use something like test/parallel/test-http2-generic-streams.js does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other things to be aware of, just sorta FYI, you don't need to do anything with these at this time unless you think you should:

  • Tests with timers like this can become unreliable if the test is competing with other tests for resources. This unreliability is introduced surprisingly often on a few platforms in CI (particularly FreeBSD, I think because test.py decides it has 48 processors or something but they're not "real" processors--never really dug into it TBH, but you get the idea). To avoid the problem, the test can be put in sequential rather than parallel.

  • If you think 10 seconds is plenty for most things, but that maybe a Raspberry Pi could use a little more time than that, use common.platformTimeout().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

client.close();
}));

req.once('data', () => req.destroy());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be common.mustCallAtLeast()'ed, to make sure it's run?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a once handler, it could be common.mustCall().

If the test will fail without the handler running, then I'm OK omitting common.mustCall(). And I'm OK including it. Either way...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. added a mustCall, since it's a once.

@Trott Trott force-pushed the add-failing-http2-test-with-writes branch from be13bfe to 5b55170 Compare April 6, 2018 22:05
@Trott
Copy link
Member

Trott commented Apr 6, 2018

This would need to be rebased due to #19854, sorry :/

I did the rebase, so no need to worry about that anymore.

@Trott
Copy link
Member

Trott commented Apr 6, 2018

@nodejs/http2 @nodejs/testing

@BridgeAR
Copy link
Member

BridgeAR commented Apr 8, 2018

@mafintosh mafintosh force-pushed the add-failing-http2-test-with-writes branch from 5b55170 to 17630b1 Compare April 9, 2018 09:58
@mafintosh
Copy link
Member Author

mafintosh commented Apr 9, 2018

Fixed the comments. PTAL @addaleax @Trott @jasnell

@mafintosh mafintosh force-pushed the add-failing-http2-test-with-writes branch from 17630b1 to cf5a405 Compare April 9, 2018 11:26
@mcollina
Copy link
Member

This test is failing and it is showing a bug :/.

I've run why-is-node-running with it, and we just have:

There are 7 handle(s) keeping the process running

# Timeout
/Users/matteo/Repositories/node/test/parallel/test-http2-many-writes-and-destroy.js:35 - setTimeout(function () {

# TCPWRAP
/Users/matteo/Repositories/node/test/parallel/test-http2-many-writes-and-destroy.js:17 - const client = http2.connect(url);

# HTTP2SESSION
(unknown stack trace)

# HTTP2SETTINGS
(unknown stack trace)

# Timeout
(unknown stack trace)

# HTTP2SESSION
(unknown stack trace)

# HTTP2STREAM
(unknown stack trace)

I have a possible fix coming, pushing directly to this PR.

@mcollina mcollina force-pushed the add-failing-http2-test-with-writes branch from cf5a405 to 9cc9a9d Compare April 11, 2018 15:39
@mafintosh
Copy link
Member Author

@mafintosh
Copy link
Member Author

🎉 @mcollina added a fix for my failing test case \o/

@@ -1190,7 +1190,7 @@ class Http2Session extends EventEmitter {
// Otherwise, destroy immediately.
if (!socket.destroyed) {
if (!error) {
setImmediate(socket.end.bind(socket));
setImmediate(socket.destroy.bind(socket));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oy! obvious and simple in hindsight.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a classic @mcollina fix :)

@jasnell
Copy link
Member

jasnell commented Apr 11, 2018

LGTM, especially with the fix :-)

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 12, 2018
@BridgeAR
Copy link
Member

Rerunning the CI because there were a couple of failures https://ci.nodejs.org/job/node-test-pull-request/14265/

@addaleax
Copy link
Member

@mafintosh Can you make sure that the CI failures are unrelated? In particular, at a quick glance https://ci.nodejs.org/job/node-test-commit-osx/17798/nodes=osx1010/console might not be…

@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 14, 2018
@apapirovski
Copy link
Member

apapirovski commented Apr 24, 2018

@mcollina
Copy link
Member

@apapirovski I've added your commit on top.

@mcollina
Copy link
Member

@apapirovski apapirovski force-pushed the add-failing-http2-test-with-writes branch from e3f9922 to c3c1f3d Compare May 10, 2018 14:18
@apapirovski
Copy link
Member

apapirovski commented May 10, 2018

CI: https://ci.nodejs.org/job/node-test-pull-request/14792/

I added some other fixes for the new changes. I also removed the changes to the http2 pipe test because if that one's getting an ECONNRESET then we shouldn't swallow it. That would indicate the fix here isn't fully correct (e.g. it's possible for us to be still writing meaningful data when the socket is destroyed).

@apapirovski apapirovski force-pushed the add-failing-http2-test-with-writes branch 2 times, most recently from 56c994c to a402353 Compare May 10, 2018 14:44
@apapirovski apapirovski force-pushed the add-failing-http2-test-with-writes branch from a402353 to 53eb584 Compare May 10, 2018 14:55
@apapirovski
Copy link
Member

Ok, the CI is green FWIW. If someone wants to give this a few more looks then we could go ahead and finally land this.

(Another CI just to be safe: https://ci.nodejs.org/job/node-test-pull-request/14805/)

@mcollina
Copy link
Member

@jasnell @addaleax @trivikr PTAL

@jasnell
Copy link
Member

jasnell commented May 12, 2018

Still LGTM

apapirovski pushed a commit that referenced this pull request May 13, 2018
Fix a bug where the socket wasn't being correctly destroyed and
adjust existing tests, as well as add additional tests.

PR-URL: #19852
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
@apapirovski
Copy link
Member

Landed in b60b183

addaleax pushed a commit that referenced this pull request May 14, 2018
Fix a bug where the socket wasn't being correctly destroyed and
adjust existing tests, as well as add additional tests.

PR-URL: #19852
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
@addaleax addaleax mentioned this pull request May 14, 2018
addaleax pushed a commit that referenced this pull request Jun 29, 2018
Fix a bug where the socket wasn't being correctly destroyed and
adjust existing tests, as well as add additional tests.

PR-URL: #19852
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Jul 9, 2018
rvagg pushed a commit that referenced this pull request Aug 16, 2018
Fix a bug where the socket wasn't being correctly destroyed and
adjust existing tests, as well as add additional tests.

PR-URL: #19852
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>

Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
@Trott Trott mentioned this pull request Nov 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http2: server.close not behaving like http1 or net
9 participants